home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Broadcaster / BroadcastLink.h < prev    next >
Text File  |  2000-06-23  |  727b  |  38 lines

  1. // BroadcastLink.h
  2.  
  3. #ifndef BroadcastLink_h
  4. #define BroadcastLink_h
  5.  
  6. #ifndef ListLink_h
  7. #include "ListLink.h"
  8. #endif
  9. #ifndef Broadcaster_h
  10. #include "Broadcaster.h"
  11. #endif
  12.  
  13. template < class Protocol >
  14. class BroadcastLink
  15.   {
  16.     typedef Broadcaster< Protocol > Source;
  17.     
  18.     private:
  19.         ListLink< Protocol > link;
  20.     
  21.     public:
  22.         BroadcastLink( Protocol& target )
  23.           : link( &target )
  24.           {}
  25.  
  26.         BroadcastLink( Protocol& target, const Source& source )
  27.           : link( &target )
  28.           {
  29.             source.receivers.Add( link, afterEnd );
  30.           }
  31.  
  32.         bool Receiving() const                        { return link.Owned(); }
  33.         void ReceiveNothing()                        { link.Owner().Remove( link ); }
  34.         void ReceiveFrom( const Source& a )        { a.receivers.Add( link, afterEnd ); }
  35.   };
  36.  
  37. #endif
  38.